<!DOCTYPE html>
<html>
<body>
<p id="description">Tests that form submissions inside an iframe generate history entries.</p>

<div id="manual-explanation" style="display: none; color: blue">When running this test outside of DRT, please click on the "Submit" button.</div>

<pre id="console"></pre>

<script>
if (window.testRunner) {
    testRunner.clearBackForwardList();
    testRunner.waitUntilDone();
    testRunner.dumpAsText();
    testRunner.dumpChildFrames();
}

var formSubmitted = false;

function submitForm()
{
    if (formSubmitted) return;
    formSubmitted = true;

    // Make sure we always generate history entries for the page that we're on.
    window.setTimeout(function() {
        if (window.eventSender) {
            var frameNode = document.getElementById('the-frame');
            var submitButtonNode = frameNode.contentWindow.document.getElementById('submit-button');
            eventSender.mouseMoveTo(
                frameNode.offsetLeft + submitButtonNode.offsetLeft + submitButtonNode.offsetWidth / 2,
                frameNode.offsetTop + submitButtonNode.offsetTop + submitButtonNode.offsetHeight / 2);
            eventSender.mouseDown();
            eventSender.mouseUp();  
        } else {
            document.getElementById('manual-explanation').style.display = '';    
        }
    }, 0);
}
</script>

<iframe id="the-frame" name="the-frame" src="resources/form-with-input-submit.html" onload="submitForm()"></iframe>

</body>
</html>
